import pandas as pd # Show all rows that are duplicates based on the column 'col_x' df[df.duplicated(['col_x'], keep=False)].sort_values(by=['col_x'])
df = df[df.duplicated(subset=['val1','val2'], keep=False)]